<?php


namespace app\api\controller;

class Member
{
    //删
    public function del()
    {
        $id = input('get.id');
        $memberModel = new \app\api\model\Member();
        if (empty($id)) {
            return $memberModel->where('member_id', '<>', '0')->delete();
        } else {
            return $memberModel->where('member_id', 'in', $id)->delete();
        }
    }

    //查
    public function sel()
    {
        $page = input('get.page');
        $limit = input('get.limit');
        $keyword = input('get.keyword');
        $condition = array();
        if (!empty($keyword)) {
            $condition[] = ['member_email', 'like', '%' . $keyword . '%'];
        }
        $memberModel = new \app\api\model\Member();
        $data = array();
        $data['code'] = 0;
        $data['msg'] = '';
        $data['count'] = $memberModel->where($condition)->count();
        $array = $memberModel->where($condition)->page($page)->limit($limit)->select();
        foreach ($array as $item) {
            $item['add_time_name'] = date('Y年m月d日 H:i:s', $item['add_time']);
        }
        $data['data'] = $array;
        header('content-type:application/javascript');
        echo json_encode($data);
        die();
    }
}